package com.mice.springbootmodel.service;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.mice.springbootmodel.common.constants.DataSourceType;
import com.mice.springbootmodel.domain.bean.UserBean;
import com.mice.springbootmodel.persistence.dao.UserDao;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author: ChenHao
 * @Date: 2018/7/11 17:01
 */
@Service
@Slf4j
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDao userDao;


    @Override
    @DS(DataSourceType.MASTER)
    public void insertOne(UserBean userBean) {
        userDao.insert(userBean);
    }

    @Override
    @DS(DataSourceType.SLAVE)
    public UserBean getOne(Long userId) {
    return userDao.selectById(userId);
    }
}